package com.meal.base.test.DesignMode.prototype;

import lombok.SneakyThrows;

/**
 * @program: meal->EnemyPlaneFactory
 * @description: 地方飞机工厂
 * @author: yangzhanghui
 * @create: 2020-04-03 10:48
 **/
public class EnemyPlaneFactory {
    //此处用痴汉模式造一个敌机原型
    private static EnemyPlane protoType = new EnemyPlane(200);

    //获取敌机克隆实例
    @SneakyThrows
    public static EnemyPlane getInstance(int x) {
        EnemyPlane clone = protoType.clone();//复制原型机
        clone.setX(x);//重新设置克隆机的x坐标
        return clone;
    }
}